package com.ruoyi.finance.controller;

import cn.hutool.core.lang.tree.Tree;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.finance.domain.PmsCategory;
import com.ruoyi.finance.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: qs
 * @Date: 2025/3/8 10:04
 * @Description:
 **/
@RestController
@RequestMapping("/catetree")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;


    //TODO 通过糊涂工具类实现3级分类
    @GetMapping("/totree")
    public AjaxResult list(){
        List<Tree<String>> tolist=categoryService.listwithTree();
        return AjaxResult.success(tolist);
    }

    //TODO 通过递归的方法获取三级分类
    @GetMapping("/keeptree")
    public AjaxResult keeptree(){
      List<PmsCategory>tolist=categoryService.keeptree();
        return AjaxResult.success(tolist);
    }
}
